package com.azdebugit.moshi.test.learn.zhuangshimoshi.test.io;

import org.junit.Test;

import java.io.*;

public class IoClient {

    @Test
    public void encrypt() {
        OutputStream os = null;
        try {
            os = new EncryptOutputStream(
                    new BufferedOutputStream(
                            new FileOutputStream(
                                    new File("D:\\ceshi\\encrypt.txt"))));
            os.write("itdebug".getBytes());
            os.flush();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                os.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    @Test
    public  void desEncrypt() {
        OutputStream os = null;
        try {
            os = new DesEncryptOutputStream(
                    new BufferedOutputStream(
                            new FileOutputStream(
                                    new File("D:\\ceshi\\desEncrypt.txt"))));
            os.write("kvfgdwi".getBytes());
            os.flush();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                os.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}